export function intervalTimes(times = 1, func, ...args){
  return new Promise(function(resolve, reject){
    let time = 1;
    const intervalIns = setInterval(async function(){
      if(time <= times){
        const res = await func(...arguments);
        if(res) {
          clearInterval(intervalIns);
          resolve(...arguments);
        }else{
          time++;
        }
      } else {
        reject(...arguments)
        clearInterval(intervalIns);
      }
    }, ...args);
  })
}

export function excuteIntervalRightNow() {
  const runFunc = arguments[0];
  runFunc();
  return setInterval(runFunc, arguments.slice(1));
}